package day03;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.nio.file.Path;

@WebServlet("/show/*")
public class ForwardServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("ForwardServlet.service()");

        String path=request.getRequestURI();

        path=path.substring(request.getContextPath().length()+request.getServletPath().length());

        System.out.println("path = " + path);

        request.getRequestDispatcher("/WEB-INF"+ path+".jsp").forward(request,response);

    }
}
